/*$(function(){  
        var $li =$("#skin li");    
        $li.click(function(){     
                switchSkin( this.id );   
                });    
        if(window.localStorage){
    
                var cookie_skin = localStorage.getItem("nowskin");   
                }else{      
                        var cookie_skin = $.cookie( "nowskin");   
                        }      
        if (cookie_skin) {  
                switchSkin( cookie_skin );   
                }     
        bindKeyDown(); 
        });*/

function SetCookie(name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (2 < argc) ? argv[2] : null;
        var path = (3 < argc) ? argv[3] : null;
        var domain = (4 < argc) ? argv[4] : null;
        var secure = (5 < argc) ? argv[5] : false;
        document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))
                        + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function GetCookie(Name) {
        var search = Name + "=";
        var returnvalue = "";
        if (document.cookie.length > 0) {
                offset = document.cookie.indexOf(search);
                if (offset != -1) {
                        offset += search.length;
                        end = document.cookie.indexOf(";", offset);
                        if (end == -1)
                                end = document.cookie.length;
                        returnvalue = unescape(document.cookie.substring(offset, end));
                }
        }
        return returnvalue;
}

var thisskin, skin;
if (window.localStorage) {
        thisskin = window.localStorage.getItem("nowskin");
} else {
        thisskin = GetCookie("nowskin");
}

skin = document.getElementById("skin");
if (thisskin != "")
        skin.href = thisskin;
else
        skin.href = "css/blackstyle.css";

function changecss(url) {
        if (url != "") {
                skin.href = "css/" + url;
                if (window.localStorage) {
                        alert(skin.href);
                        window.localStorage.setItem("nowskin", "css/" + url);
                } else {
                        var expdate = new Date();
                        expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 30));
                        SetCookie("nowskin", url, expdate, "/", null, false);
                }
        }
        $.mobile.changePage("index.html", {
                transition : "none"
        });
}
/*
 * function switchSkin(skinName){ $("#"+skinName).addClass("selected")
 * .siblings().removeClass("selected");
 * $("#cssfile").attr("href",skinName+"/css/index.css");
 * if(window.localStorage){ localStorage.setItem("MyCssSkin" , skinName); }else{
 * $.cookie( "MyCssSkin" , skinName); } }
 */